
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author djdracku
 */
public class Ventana {
   public static void main(String args[]){

    TextArea are;
    Frame f=new Frame();

   
       //Panel p1=new Panel();
    final Button b1=new Button("AGREGAR");
    final TextArea ar=new TextArea();
    final TextField t1=new TextField();
        Button b2=new Button("RESET");
        t1.setEditable(true);
        f.setLayout(new FlowLayout());
       // p1.setLayout(new FlowLayout());
        Menu me = new Menu("Archivo");
        MenuBar bar = new MenuBar();
        MenuItem mi1 = new MenuItem("Nuevo");
        MenuItem mi2 = new MenuItem("Salir");


       Panel p = new Panel();
        Panel p1 = new Panel();
        p.setLayout(new GridLayout(1,2));
        p.add(p1);
        me.add(mi1 );
        me.add(mi2);
        bar.add(me);
        f.setMenuBar(bar);

        t1.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e){
            if(e.getKeyCode()==10){
                ar.append("\n"+t1.getText());
            }
        }
       });
       b2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ar.setText(" ");
                t1.setText(" ");
            }
        });
        b1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ar.append("\n"+t1.getText());
            }
        });
        b1.addMouseListener(new MouseAdapter() {
            public void mouseEntered(MouseEvent e){
                b1.setBackground(Color.BLUE);
            }
            public void mouseExited(MouseEvent e){
                b1.setBackground(Color.GRAY);
            }
        });

        
        mi1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                 ar.setText(" ");
                 t1.setText(" ");
            }
        });

         mi2.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });

        
        f.addWindowListener(new WindowAdapter() {

         public void windowClosing(WindowEvent e) {
                System.exit(0);
            }


        });
        f.add(ar,"Center");
        f.add(p,"SOUTH");
        
        p1.add(b1,"South");

        p1.add(t1);
        p1.add(b2);

        f.add(p1);

        f.setSize(400, 400);
        f.setVisible(true);
      


}
}
